Kanzi 3.9.14
kanzi::TaskDispatcherBase Class Referenceabstract

Base class for TaskDispatcher implementation. More...

#include <kanzi/core.ui/platform/task_dispatcher/common/task_dispatcher_base.hpp>

Inheritance diagram for kanzi::TaskDispatcherBase:
[legend]

Public Types

typedef function< void()> Task
 Task is a callback that is dispatched by TaskDispatcher and executed on a specific UI thread.
 

Public Member Functions

void cleanUpTasks ()
 Clean up tasks until no tasks remain.
 
size_t executeTasks ()
 Executes the tasks that have been dispatched to the UI thread.
 
bool isEmpty () const
 Indicates whether the task dispatcher does not contain pending tasks.
 
bool isQuitting () const
 Indicates whether the task dispatcher is quitting.
 
virtual void notifyTasksAvailable ()=0
 Notifies this class that tasks are available.
 
virtual void notifyTasksConsumed ()=0
 Notifies this class that tasks have been consumed.
 
void setDomain (Domain *domain)
 Setter for domain.
 
void setQuitting (bool flag)
 Set the quitting flag state.
 
void submit (Task task)
 Submits a task for execution in the UI thread.
 

Protected Member Functions

 TaskDispatcherBase ()
 Constructor.
 
virtual ~TaskDispatcherBase ()
 Destructor.
 

Detailed Description

Base class for TaskDispatcher implementation.

Member Typedef Documentation

◆ Task

Task is a callback that is dispatched by TaskDispatcher and executed on a specific UI thread.

Constructor & Destructor Documentation

◆ TaskDispatcherBase()

kanzi::TaskDispatcherBase::TaskDispatcherBase ( )
explicitprotected

Constructor.

◆ ~TaskDispatcherBase()

virtual kanzi::TaskDispatcherBase::~TaskDispatcherBase ( )
protectedvirtual

Destructor.

Member Function Documentation

◆ submit()

void kanzi::TaskDispatcherBase::submit ( Task task)

Submits a task for execution in the UI thread.

The task will be dispatched to and executed on the UI thread that this task dispatcher belongs to. All submitted tasks are executed sequentially in the order that they were received. You can call this function from any thread. Tasks may submit new tasks during their execution. Tasks submitted by executing tasks are queued for execution during the next frame. This means that tasks may safely submit themselves without risk for infinite loops.

◆ executeTasks()

size_t kanzi::TaskDispatcherBase::executeTasks ( )

Executes the tasks that have been dispatched to the UI thread.

Tasks will be removed from the task queue after execution. New tasks submitted during the execution will be queued for execution by the next call to this function. Kanzi calls this function automatically. Custom code may not attempt to call this function. This function can only be called from the UI thread that this dispatcher belongs to. No guarantee of exception safety; both the function itself and the tasks it executes may throw exceptions. Calling this function from a thread other than the one this dispatcher belongs to will throw a logic_error exception. Calling this function while it is still executing tasks will throw a logic_error exception.

Returns
Number of tasks that were executed.

◆ cleanUpTasks()

void kanzi::TaskDispatcherBase::cleanUpTasks ( )

Clean up tasks until no tasks remain.

Sets the quitting flag, that the tasks can use to check if new tasks should be posted.

◆ isEmpty()

bool kanzi::TaskDispatcherBase::isEmpty ( ) const

Indicates whether the task dispatcher does not contain pending tasks.

◆ notifyTasksAvailable()

virtual void kanzi::TaskDispatcherBase::notifyTasksAvailable ( )
pure virtual

Notifies this class that tasks are available.

This is an internal function.

Implemented in kanzi::TaskDispatcher.

◆ notifyTasksConsumed()

virtual void kanzi::TaskDispatcherBase::notifyTasksConsumed ( )
pure virtual

Notifies this class that tasks have been consumed.

This is an internal function.

Implemented in kanzi::TaskDispatcher.

◆ setDomain()

void kanzi::TaskDispatcherBase::setDomain ( Domain * domain)

Setter for domain.

Parameters
domainPointer to domain

◆ isQuitting()

bool kanzi::TaskDispatcherBase::isQuitting ( ) const

Indicates whether the task dispatcher is quitting.

This flag is set before the emptying of the task queue begins.

Returns
True if quitting, false if not.

◆ setQuitting()

void kanzi::TaskDispatcherBase::setQuitting ( bool flag)

Set the quitting flag state.

Called by the system before emptying the task dispatcher.

Parameters
flagNew quitting flag state.

The documentation for this class was generated from the following file: